package com.talent.jiwen;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;

import com.talent.jiwen.base.BaseFragment;
import com.talent.jiwen.util.Validators;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

public class PasswordFragment extends BaseFragment {
    @BindView(R.id.phoneEt)
    EditText phoneEt;
    @BindView(R.id.passwordEt)
    EditText passwordEt;
    private OnPasswordFocusChangedListener listener;

    public void setListener(OnPasswordFocusChangedListener listener) {
        this.listener = listener;
    }

    @Override
    protected void initData() {
        passwordEt.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View view, boolean b) {
                if(null != listener){
                    listener.passwordEtFocus(b);
                }
            }
        });
    }

    @Override
    protected int provideContentViewId() {
        return R.layout.fragment_password;
    }


    /**获取手机号
     *
     * @return
     */
    public String getPhoneNumber(){
        return phoneEt.getText().toString();
    }

    /**设置手机号
     *
     * @param phone
     */
    public void setPhomeNumer(String phone){
        if (!Validators.isEmpty(phone)){
            phoneEt.setText(phone);
        }
    }

    /**获取密码
     *
     * @return
     */
    public String getPassword(){
        return passwordEt.getText().toString();
    }

    /**设置密码
     *
     * @param password
     */
    public void setPassword(String password){
        passwordEt.setText(password);
    }

    public interface OnPasswordFocusChangedListener{
        void passwordEtFocus(boolean hasFocus);
    }
}
